package config

import (
	"fmt"
	"log"

	"gorm.io/driver/mysql"
	"gorm.io/gorm"
)

var DB *gorm.DB

func InitDB() {
	dsn := "ubuntu:Ld123456.@tcp(119.29.231.143:3306)/new_quant?charset=utf8mb4&parseTime=True&loc=Local"
	db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{})
	if err != nil {
		log.Fatal("Failed to connect to database:", err)
	}

	// 不需要自动迁移，因为表已经存在
	DB = db
	fmt.Println("Database connected successfully")
}
